import os
from dataclasses import dataclass

from .exceptions import ConfigParseError


@dataclass
class DatabaseConfig:
    db_url: str


def get_str_env(key: str) -> str:
    value = os.getenv(key)
    if not value:
        raise ConfigParseError(f'{key} is not set')
    return value


def load_database_config():
    return DatabaseConfig(db_url=get_str_env('DB_URI'))
